package UML;

public class A3 {
    class Subject {
        private String name;
        private String description;

        public Subject(String name, String description) {
            this.name = name;
            this.description = description;
        }

        public String getName() {
            return name;
        }

        public String getDescription() {
            return description;
        }
    }

    class Instructor {
        private Department department;
        private Subject[] courses;

        public Instructor(Department department) {
            this.department = department;
            this.courses = new Subject[0];
        }

        public void addCourse(Subject course) {
            Subject[] newCourses = new Subject[courses.length + 1];
            System.arraycopy(courses, 0, newCourses, 0, courses.length);
            newCourses[courses.length] = course;
            courses = newCourses;
        }

        public Department getDepartment() {
            return department;
        }

        public Subject[] getCourses() {
            return courses;
        }
    }

    class Department {
        private Instructor[] instructors;
        private Subject[] subjects;

        public Department() {
            instructors = new Instructor[0];
            subjects = new Subject[0];
        }

        public void addInstructor(Instructor instructor) {
            Instructor[] newInstructors = new Instructor[instructors.length + 1];
            System.arraycopy(instructors, 0, newInstructors, 0, instructors.length);
            newInstructors[instructors.length] = instructor;
            instructors = newInstructors;
        }

        public void addSubject(Subject subject) {
            Subject[] newSubjects = new Subject[subjects.length + 1];
            System.arraycopy(subjects, 0, newSubjects, 0, subjects.length);
            newSubjects[subjects.length] = subject;
            subjects = newSubjects;
        }

        public Instructor[] getInstructors() {
            return instructors;
        }

        public Subject[] getSubjects() {
            return subjects;
        }
    }

    class School {
        private Department[] departments;
        private Student[] students;

        public School() {
            departments = new Department[0];
            students = new Student[0];
        }

        public void addDepartment(Department department) {
            Department[] newDepartments = new Department[departments.length + 1];
            System.arraycopy(departments, 0, newDepartments, 0, departments.length);
            newDepartments[departments.length] = department;
            departments = newDepartments;
        }

        public void addStudent(Student student) {
            Student[] newStudents = new Student[students.length + 1];
            System.arraycopy(students, 0, newStudents, 0, students.length);
            newStudents[students.length] = student;
            students = newStudents;
        }

        public Department[] getDepartments() {
            return departments;
        }

        public Student[] getStudents() {
            return students;
        }
    }

    class Student {
        private String name;
        private Subject[] courses;

        public Student(String name) {
            this.name = name;
            this.courses = new Subject[0];
        }

        public void addCourse(Subject course) {
            Subject[] newCourses = new Subject[courses.length + 1];
            System.arraycopy(courses, 0, newCourses, 0, courses.length);
            newCourses[courses.length] = course;
            courses = newCourses;
        }

        public String getName() {
            return name;
        }

        public Subject[] getCourses() {
            return courses;
        }
    }
}